﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Windows.Data;

namespace EditorExe
{
    class ValueTypeConverter : IValueConverter
    {

        public ValueTypeConverter()
        {
            
        }

        public Type TypeConverterType { get; set; }

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var typeConverter = Activator.CreateInstance(TypeConverterType) as TypeConverter;
            return typeConverter.ConvertTo(value, targetType);
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var typeConverter = Activator.CreateInstance(TypeConverterType) as TypeConverter;
            return typeConverter.ConvertFrom(value);
        }
    }
}
